<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">

<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<script type="text/javascript" src="lib/PIE_IE678.js"></script>
<![endif]-->
<link href="css/H-ui.min.css" rel="stylesheet" type="text/css" />
<link href="css/H-ui.admin.css" rel="stylesheet" type="text/css" />
<link href="css/style.css" rel="stylesheet" type="text/css" />
<link href="lib/Hui-iconfont/1.0.1/iconfont.css" rel="stylesheet" type="text/css" />

<title>视频列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 视频管理 <span class="c-gray en">&gt;</span> 视频列表 <a class="btn btn-success radius r mr-20" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	
	<div class="text-c pb-20"> 
					<select name="menutype" class="input-text"  style="width:250px" class="select" id="menu">
						<option value="-1">请选择一个视频类型</option>
						<option value="1">月子馆</option>
						<option value="2">美妈在美国</option>
						<option value="3">赴美生子那些事</option>
					</select>
		<button type="submit" class="btn btn-success radius"  onClick="demo()"id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
	</div>

	<div class="cl pd-5 bg-1 bk-gray"> 
	<span class="l">
	<a href="javascript:;" onclick="delBatch()" class="btn btn-danger radius"><i class="Hui-iconfont"></i> 批量删除</a>
	<a class="btn btn-primary radius" onclick="video_add('添加视频','superb-add.html')" href="javascript:;"><i class="Hui-iconfont">&#xe600;</i> 添加视频</a>
	</span> <span class="r">共有数据：<strong id="sum">0</strong> 条</span> </div>
	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-hover table-sort">
			<thead>
				<tr class="text-c">
				<th><input name="" type="checkbox" value=""></th>
					<th width="100">名称</th>
					<th width="100">图片</th>
					<th width="90">视频URL</th>
					<th width="100">视频简介</th>
					<th width="150">更新时间</th>
					<th width="60">评论</th>
					<th width="100">操作</th>
				</tr>
			</thead>

			<tbody id="str">
				<!-- <tr class="text-c">
					<td>001</td>
					<td>圣嘉尔</td>
					<td><img src="pic/200x150.jpg" alt=""></td>
					<td>圣嘉尔视频URL</td>
					<td>简介</td>
					<td>2014-6-11 11:11:42</td>
					<td> <a title="评论" href="javascript:;" onclick="comment('评论','comment-list.html','4','800','600')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">评论</i></a></td>
					<td class="td-manage"><a style="text-decoration:none" class="ml-5" onClick="video_edit('视频编辑','superb-add.html','10001')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a> <a style="text-decoration:none" class="ml-5" onClick="video_del(this,'10001')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
				</tr> -->
			</tbody>
		</table>
	</div>
</div>
<div id="page1" style="float:right"></div>
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="lib/layer/1.9.3/layer.js"></script> 
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script> 
<script type="text/javascript" src="js/H-ui.js"></script> 
<script type="text/javascript" src="js/H-ui.admin.js"></script> 
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script> 
<script type="text/javascript">


$(function(){
demo();
//*****************************************

});

function demo(curr){
	var key='';
	var type=''
		
	var options=$("#menu option:selected"); 
	if(options.val()!= -1){
		type=options.val()	;
	}
// alert(key);
    $.ajax( {  
		     url:'/baby/liveVideoShow/queryLiveVideoShow',// 跳转到 action  
		     data:{
		     	pageNum : curr
		     	,key:key
		     	,type:type
		     },  
		     type:'post',  
		     cache:false,  
		     dataType:'json',  
		     success:function(data) {
		    	 if(data.code =="5000"){
		    		 alert("没有找到内容")
		    	 }
		         if(data.code =="2000" ){ 
		             // alert(data.data.totalRowNumber); 
		             // console.log(data); 
		              if(data.data==null ){
		             	alert("没有找到数据");
		             	return
		             }
		             var datalist= data.data.dataList;
		             
		             //拼页面
		             var s=data.data.totalRowNumber;
		             document.getElementById("sum").innerHTML=s
		            var comm='';
		             var htmlstr='';
		             var top='';
		             for (var i=0;i<datalist.length;i++){
		             		var obj=datalist[i];//获取单个数据对象
		             	//拼页面
		             // console.log(obj); 
 							var comm='';
 							var img='images/nullimg.jpg';
 							if(obj.img != null){
 								img=obj.img.realPicUrl;
 							}
			         	    var comurl="comment-list.html?sid="+obj.sid
			             
					        if(obj.commentNew){
					        	comm='<td> <a style="color:red;" title="评论" href="javascript:;" onclick="comment(\''+comurl+'\')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">评论</i></a></td>'
					        }else{
					        	comm='<td> <a style="color:blue;" title="评论" href="javascript:;" onclick="comment(\''+comurl+'\')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">评论</i></a></td>'
					        }
					      	if(obj.top){
					      		top='<a style="text-decoration:none" class="ml-5" onClick="is_top(\''+obj.sid+'\',\'y\')" href="javascript:;" title="置顶"><i class="Hui-iconfont">&#xe699;</i></a>'
									+'<a style="text-decoration:none" class="ml-5" onClick="is_top(\''+obj.sid+'\',\'n\')" href="javascript:;" title="取消置顶"><i class="Hui-iconfont">&#xe698;</i></a>'
					      	}else{
					      		top='<a style="text-decoration:none" class="ml-5" onClick="is_top(\''+obj.sid+'\',\'y\')" href="javascript:;" title="置顶"><i class="Hui-iconfont">&#xe699;</i></a>'
					      	}
			         	    
					        htmlstr+='	<tr class="text-c">' 
								+'<td width="30"><input name="del" type="checkbox" value="'+obj.sid+'"></td>'
								+'<td>'+obj.name+'</td>'
								+'<td><img style="max-height:100px;max-width:100px;" src="'+img+'" alt=""></td>'
								+'<td width="90">'+obj.videoUrl+'</td>'
								+'<td width="90">'+obj.videoIntroduce+'</td>'
								+'<td>'+obj.createTime+'</td>'
								+comm
								+'<td class="td-manage">'
								+top
								+'<a style="text-decoration:none" class="ml-5" onClick="video_edit(\''+obj.sid+'\')" href="javascript:;" title="编辑"><i class="Hui-iconfont">&#xe6df;</i></a>'
								+'<a style="text-decoration:none" class="ml-5" onClick="video_del(this,\''+obj.sid+'\')" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>'
								+'</tr>'
		             	
					}
					document.getElementById("str").innerHTML =htmlstr
		             laypage({
					    cont: $('#page1'), //容器。值支持id名、原生dom对象，jquery对象,
					    pages:data.data.totalRowNumber, //总页数
					    skip: true, //是否开启跳页
					    groups: 5, //连续显示分页数
					    curr: data.data.currentPage, //当前页
					    pages:data.data.totalPage,
					    jump: function(obj, first){
					    //得到了当前页，用于向服务端请求对应数据
					    var curr = obj.curr;
					    	if(!first){
								demo(curr);	
					    	}
						}
					});

		         }else if(data.code =="5001" ){
					alert(data.message); 
					 window.parent.location.href='http://localhost:8080/baby/resource/admin/login.html'
	             	console.log(data);  
		         	 
		         }  
		      }, error : function() {      
		             // view("异常！");  
		          alert("异常！");  
		     }  
		});
};


/*****************************/
 
 function delBatch(){
	 layer.confirm('确认要删除吗？',function(index){
		var sid=''
			$('input:checkbox[name="del"]:checked').each(function(){ 
				sid+=$(this).val()+','; 
			}); 
			sid=sid.substring(0,sid.length-1);
			
			console.log(sid);
			
	  $.ajax( {  
		     url:'/baby/liveVideoShow/deleteBatchLiveVideoShow',// 跳转到 action  
		     data:{
		    	 jsonStr:sid
		     },  
		     type:'post',  
		     cache:false,  
		     dataType:'json',  
		     success:function(data) { 
		         if(data.code =="2000" ){ 
					
					window.location.reload();
		         }else{
		        	 layer.msg(data.message,{icon:1,time:1000});
		         }
		     }, error : function() {      
		             // view("异常！");  
		             console.log("删除出现异常");
		     }  
		});    
			
	 });
}


/*视频-添加*/
function video_add(title,url){
	var index = layer.open({
		type: 2,
		title: title,
		content: url
	});
	layer.full(index);
}


/*视频-编辑*/
function video_edit(id){
	var title="视频编辑";
	var url="superb-update.html?sid="+id
	 var index = layer.open({
	 	type: 2,
	 	title: title,
	 	content: url
	 });
	 layer.full(index);
}

/*视频-删除*/
function video_del(obj,id){
	
	layer.confirm('确认要删除吗？',function(index){

		  $.ajax( {  
		     url:'/baby/liveVideoShow/deleteLiveVideoShow',// 跳转到 action  
		     data:{
		     	key:id
		     },  
		     type:'post',  
		     cache:false,  
		     dataType:'json',  
		     success:function(data) { 
		         if(data.code =="2000" ){ 

					layer.msg('已删除!',{icon:1,time:1000});
					
					window.location.reload();
		         }
		     }, error : function() {      
		             // view("异常！");  
		          alert("异常！");  
		     }  
		});    

		
	});
}

/*视频-置顶*/
function is_top(sid,top){
	
		  $.ajax( {  
		     url:'/baby/liveVideoShow/updateTopLiveVideoShow',// 跳转到 action  
		     data:{
		    	 sid:sid,
		    	 type:top
		     },  
		     type:'post',  
		     cache:false,  
		     dataType:'json',  
		     success:function(data) { 
		         if(data.code =="2000" ){ 
				//	layer.msg('已删除!',{icon:1,time:1000});
					window.location.reload();
		         }else{
		        	 alert(data.message);
		         }
		     }, error : function() {      
		             // view("异常！");  
		          alert("异常！");  
		     }  
		});    
}


// 打开评论
function comment(url){

	layer_show('评论',url,"800","800");
}
</script>
</body>
</html>